package com.cw1.adapter.objectadapter;

import com.cw1.adapter.classadapter.Voltage220V;

import java.util.Objects;

/**
 * @Author qiuMi
 * @description 电压 - 适配器类
 * @Date 2022-11-06 17:44
 **/
public class VoltageAdapter implements IVoltage5V {

    private Voltage220V voltage220V;

    /**
     * 利用构造器传入 220V电压
     *
     * @param voltage220V voltage220V
     */
    public VoltageAdapter(Voltage220V voltage220V) {
        this.voltage220V = voltage220V;
    }

    /**
     * 电压 - 适配器转换
     *
     * @return int
     */
    @Override
    public int outPut5V() {
        int dstV = 0;
        // 通过私有属性来直接拿去到 220V电压
        if (Objects.nonNull(voltage220V)) {
            int srcV = voltage220V.outPut220V();
            // 电压转换
            dstV = srcV / 44;
        }
        return dstV;
    }
}
